﻿

'*******************************************************************
' Program: Data Center Visio Rack Tool
' Author: Albert E Edlund
' Date:
'
' Purpose:
'
'
'
'*******************************************************************


Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging


Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports DC_Rack.Objects
Imports DC_Rack.Objects.dc_Product


Public Class dc_SlotBase
    Implements INotifyPropertyChanged


#Region "Events"

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Private Sub OnPropertyChanged(ByVal info As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub

#End Region

#Region " Enumerations "

    Public Enum EndPoints
        endBottom = 1
        endTop = 2
        endLeft = 1
        endRight = 2
    End Enum


#End Region

#Region " Properties and Definitions "


    Public Const constslotProductKey As Int32 = -1
    Public Const constslotId As String = "na"
    Public Const constslotProductView As dc_Product.View = View.viewUnknown
    Public Const constslotEndPoints As String = "[]"
    Public Const constslotPairValid As Boolean = False
    Public Const constslotBuildDate As Date = #1/1/2001#

    Private m_slotproductkey As Int32
    Property slotProductKey() As Int32
        Get
            Return Me.m_slotproductkey
        End Get
        Set(ByVal value As Int32)
            If IsNumeric(value) Then
                Me.m_slotproductkey = value
            Else
                Me.m_slotproductkey = constslotProductKey
            End If
        End Set
    End Property

    Private m_slotproductview As dc_Product.View
    Property slotProductView() As dc_Product.View
        Get
            Return Me.m_slotproductview
        End Get
        Set(ByVal value As dc_Product.View)
            If Not TypeDescriptor.GetConverter(GetType(dc_Product.View)).IsValid(value) Then
                'Throw New ArgumentException()
                value = dc_Product.View.viewRear
            End If
            Me.m_slotproductview = value
        End Set
    End Property

    Private m_slotid As String
    Property slotId() As String
        Get
            Return Me.m_slotid
        End Get
        Set(ByVal value As String)
            Me.m_slotid = LCase(CStr(value))
        End Set
    End Property

    Private m_slotpairvalid As Boolean
    Property slotPairValid() As Boolean
        Get
            Return Me.m_slotpairvalid
        End Get
        Set(ByVal value As Boolean)
            m_slotpairvalid = value
        End Set
    End Property

    Private m_slotbuilddate As Date
    Public Property slotBuildDate() As Date
        Get
            Return Me.m_slotbuilddate
        End Get
        Set(ByVal value As Date)
            Me.m_slotbuilddate = value
        End Set
    End Property

    ' this is a csv collection
    Private m_slotendpoints As String
    Public Property slotEndPoints() As String
        Get
            Return Me.m_slotEndPoints
        End Get
        Set(ByVal value As String)
            Me.m_slotendpoints = value
        End Set
    End Property

    Private m_colendpoints As Collection(Of EndPoints)
    Public Property _colEndPoints() As Collection(Of EndPoints)
        Get
            Return Me.m_colendpoints
        End Get
        Set(ByVal value As Collection(Of EndPoints))
            Me.m_colendpoints = value
        End Set
    End Property


    Private m_slotKey As String
    Public Property _slotKey() As String
        Get
            Return Me.m_slotKey
        End Get
        Set(ByVal value As String)
            Me.m_slotKey = value
        End Set
    End Property


#End Region

#Region " Constructor "

    Public Sub New()
        initProperties()
    End Sub

    Public Sub New _
            (ByVal intProdKey As Int32, _
             ByVal intProdView As Int16, _
             ByVal strSlotId As String)

        initProperties()
        slotProductKey = intProdKey
        slotProductView = intProdView
        slotId = strSlotId
        ' anything past the second underscore is the name (since it may have embedded underscores)
        _slotKey = CStr(slotProductKey) & "_" & CStr(intProdView) & "_" & strSlotId

    End Sub

#End Region


#Region " methods "

    '
    '
    '
    Public Sub initProperties()

        Try

            slotProductKey = constslotProductKey
            slotId = constslotId
            slotProductView = constslotProductView
            slotPairValid = constslotPairValid
            slotEndPoints = constslotEndPoints
            _colEndPoints = New Collection(Of EndPoints)
            _slotKey = ""

        Catch ex As Exception
            Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
            If (rethrow) Then
                Throw
            End If
        End Try
    End Sub


#End Region

End Class


